import { postAction } from '@/api/manage'

export default {
  props: {
    id: [String, Number],
    stationCode: String
  },
  data() {
    return {
      url: '',
      tableData: []
    }
  },
  watch: {
    id() {
      this.getData()
    },
    stationCode() {
      this.getData()
    }
  },
  mounted() {
    this.getData()
  },
  methods: {
    getData() {
      if (this.url) {
        const params = this.getParams()
        if (params) {
          postAction(this.url, params).then(res => {
            this.tableData = res.data
          })
        } else {
          this.tableData = []
        }
      }
    },
    getParams() {
      const { id, stationCode } = this
      if (id) {
        return {
          id,
          stationCode
        }
      }
    }
  }
}